<template>
  <SearchForm
    v-model:search-items="searchItems"
    :form-config="formConfig"
    :cache-key="'dictDataSearch'"
    @search="handleSearch"
  />
</template>

<script setup>
import { ref } from "vue";
import SearchForm from "@/components/CommonSearch/SearchForm.vue";

const emit = defineEmits(["search"]);

// 定义搜索项配置
const searchItems = ref([
  {
    label: "字典数据名",
    prop: "dict_data_name",
    component: "el-input",
    visible: true,
    span: { lg: 8, md: 8, sm: 12, xs: 24 },
    props: {
      clearable: true,
      placeholder: "请输入字典数据名",
    },
  },
  {
    label: "字典数据值",
    prop: "dict_data_code",
    component: "el-input",
    visible: true,
    span: { lg: 8, md: 8, sm: 12, xs: 24 },
    props: {
      clearable: true,
      placeholder: "请输入字典数据值",
    },
  },
]);

/** 表单配置 */
const formConfig = ref({
  dict_data_name: "",
  dict_data_code: "",
});

/** 处理搜索 */
const handleSearch = (formData) => {
  emit("search", { ...formData });
};

defineExpose({
  resetFields: () =>
    (formConfig.value = { dict_data_name: "", dict_data_code: "" }),
});
</script>
